<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表白墙</title>
    <style>
        /* 清理浏览器默认布局 */
        * {
            margin: 0px;
            padding: 0px;
        }

        /* 让整个窗体居中 */
        .container {
            width: 400px;
            margin: 0 auto;
        }

        h1 {
            text-align: center;
            margin-bottom: 40px;
        }

        p {
            text-align: center;
            color: gray;
            line-height: 63px;
        }

        /* 让编辑框 弹性布局 进行水平居中和垂直居中 */
        .div1 {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        /* 让编辑框和文字之间有一定的间距 */
        .edit {
            margin-bottom: 20px;
            width: 200px;
            height: 30px;
        }

        span {
            width: 70px;
            margin-bottom: 20px;
        }

        .submit {
            background-color: rgb(255, 157, 0);
            color: white;
            width: 270px;
            height: 40px;
            border-radius: 5px;
            border: none;
        }

        /* 提交点击 */
        .submit:active {
            background-color: gray;
        }
    </style>

</head>

<body>
    <div class="container">
        <h1>表白墙</h1>
        <p>输入后点击提交，会将信息显示在表格中</p>
        <div class="div1">
            <span>谁 ： </span><input type="text" class="edit">
        </div>

        <div class="div1">
            <span>对谁 ： </span><input type="text" class="edit">
        </div>

        <div class="div1">
            <span>说什么 ： </span><input type="text" class="edit">
        </div>

        <div class="div1">
            <input type="button" value="提交" class="submit" onclick="Submit()">
        </div>

    </div>

</body>

<script>
    function Submit() {
        let edits = document.querySelectorAll('.edit');
        console.dir(edits);

        let from = edits[0].value;
        let to = edits[1].value;
        let message = edits[2].value;
        console.log(from + " " + to + " " + message);

        // 添加节点
        let div = document.createElement("div");
        div.className = "div1";
        div.innerHTML = "谁" + from + "对谁" + to + "说" + message;
        console.log(div);
        let container = document.querySelector('.container');
        container.appendChild(div);
    }
</script>

</html>